feat(ddl): publish systemplane schema + default seed as importable artifacts#26
Conversation
Expose the canonical systemplane DDL and a universal default seed from the root systemplane package so consumers can fold schema provisioning into their own migration pipelines instead of relying on the lib's runtime runSchema. - Add ddl/schema.sql (byte-faithful to runtime runSchema; table systemplane_entries + systemplane_notify_v3() + INSERT/DELETE and UPDATE triggers on channel systemplane_changes; static, no placeholders). - Add ddl/default_seed.sql (neutral runtime_config baseline, INSERT ... ON CONFLICT (namespace, "key") DO NOTHING). - Embed both via //go:embed and expose SchemaSQL() / DefaultSeedSQL(). - Add unit tests; the schema test asserts the embed contains the canonical fragments the runtime emits (drift-prevention via consistency test). - Update CHANGELOG.
|
Caution Review failedPull request was closed or merged during review No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (5)
WalkthroughThis PR exports canonical, embedded SQL artifacts ( ChangesCanonical SQL DDL and Seed Artifacts
Comment |
🔍 PR Validation Summary🚫 PR Blocked — 1 blocking failure
|
🔒 Security Scan Results —
|
| Stage | Status | Blocking? |
|---|---|---|
| Filesystem Scan | ✅ Clean | — |
| Docker Image Scan | ➖ Skipped | — |
| Docker Hub Health Score | ➖ Skipped | — |
| Pre-release Version Check | ✅ Clean | — |
Trivy
Filesystem Scan
✅ No vulnerabilities or secrets found.
Pre-release Version Check
✅ No unstable version pins found.
📊 Unit Test Coverage Report:
|
| Metric | Value |
|---|---|
| Overall Coverage | 80.6% ✅ PASS |
| Threshold | 80% |
Coverage by Package
| Package | Coverage |
|---|---|
github.com/LerianStudio/lib-systemplane/admin |
88.4% |
github.com/LerianStudio/lib-systemplane/internal/client |
80.7% |
github.com/LerianStudio/lib-systemplane/internal/debounce |
73.1% |
github.com/LerianStudio/lib-systemplane/internal/manager |
87.4% |
github.com/LerianStudio/lib-systemplane/internal/mongodb |
97.5% |
github.com/LerianStudio/lib-systemplane/internal/postgres |
100.0% |
github.com/LerianStudio/lib-systemplane |
94.8% |
Generated by Go PR Analysis workflow
What
Expose the canonical systemplane DDL and a universal default seed from the importable root package (
github.com/LerianStudio/lib-systemplane, packagesystemplane) so consumers can fold systemplane schema provisioning into their own migration pipelines (e.g. a consumer'smake systemplane-ddlcopying the artifacts intomigrations/), instead of relying on the lib's runtimerunSchema.Public API (stable contract — consumers code against these exact names)
In package
systemplane(repo root):func SchemaSQL() string— full schema DDL.func DefaultSeedSQL() string— universal default seed INSERTs.Both are backed by
//go:embedofddl/schema.sqlandddl/default_seed.sql.Artifacts
ddl/schema.sqlByte-faithful to the runtime DDL emitted by
internal/postgres/postgres_schema.goandinternal/manager/schema.go, with the table fixed tosystemplane_entriesand the NOTIFY channel fixed tosystemplane_changes(the Manager'sdefaultChannel). The published artifact is static — no table/channel placeholders. It contains, in order:CREATE TABLE IF NOT EXISTS systemplane_entries (...)CREATE OR REPLACE FUNCTION systemplane_notify_v3()— byte-copied as-is, not modified/upgraded.DROP TRIGGER IF EXISTS+CREATE TRIGGER systemplane_notify_trigger AFTER INSERT OR DELETE ...andsystemplane_notify_update_trigger AFTER UPDATE ... WHEN (OLD IS DISTINCT FROM NEW).ddl/default_seed.sqlUniversal neutral baseline for namespace
runtime_config,INSERT ... ON CONFLICT (namespace, "key") DO NOTHING. JSONB encoding matches the lib's runtimeseedDefaults(json.Marshal).Drift prevention
Chose the consistency test (the documented fallback), not a runtime refactor. Reason: the runtime
runSchemain bothinternal/postgresandinternal/managerparameterizes table/channel viafmt.Sprintfand carries#nosecidentifier-validation invariants; rendering those two paths from a single static embed would be invasive and would force placeholder logic back into a deliberately-static artifact. Instead,ddl_test.goasserts the embeddedddl/schema.sqlcontains every canonical fragment the runtime emits, so a future runtime DDL change forces the embed to be updated in lock-step.Debatable universal default-seed values — please review
These become every consumer's default, so flagging the judgment calls:
rate_limit.enabled = false— seeded off as a neutral universal default. A consumer that expects rate limiting on by default would need to override.cors.allowed_origins = ""— intentionally empty/neutral (no dev origin baked in).cors.allowed_methods = "GET,POST,PUT,PATCH,DELETE,OPTIONS"andcors.allowed_headers = "Origin,Content-Type,Accept,Authorization"— reasonable defaults but opinionated; confirm the exact method/header lists.app.log_level="info",rate_limit.max=100,rate_limit.expiry_sec=60,idempotency.require_redis=false,idempotency.duplicate_guard_ttl_seconds=300.Verification
go build ./...— greengo vet ./...— greengo test -tags=unit ./...— green (206 passed)golangci-lint run --build-tags unit ./...— no issuesNote
No tag created/pushed — the human tags the beta after approval.
🤖 Generated with Claude Code